/*
 *  Math.h
 *  RTDemo
 *
 *  Created by steveca  on 10/05/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef __MATH_H__
#define __MATH_H__

#include <math.h>

namespace RTRT
{    
    /** Class to provide access to common mathematical functions.
    
     @remarks
     Most of the maths functions are aliased versions of the C runtime
     library functions. They are aliased here to provide future
     optimisation opportunities, either from faster RTLs or custom
     math approximations.
     */
    
    class Math
        {
        public:
            Math() {}
            ~Math() {}
            
        public:
			// Double abs function
            static inline double Abs(double value) { return fabs(value); }
			
			// Float abs function
			static inline float Fabs(float value) { return fabsf(value); }
            static inline float Sqr(float value) { return value * value; }
            static inline float Sqrt(float value) { return (float)sqrt(value); }
			static inline float InvSqrt(float value) { return 1.0f / sqrt(value); }
            static inline float Sin(const Radian& fValue) {
                return (float)( sin( fValue.valueRadians()) );
            }
            
            static inline float Cos(const Radian& fValue) {
                return (float)( cos( fValue.valueRadians()) ); 
            }
            
			static inline float Exp(const float fValue) {
				return (float) exp(fValue);
			}
			
			static inline double Exp(const double dValue) {
				return (double) exp(dValue);
			}
			
            static Radian ASin(float value);
            static Radian ACos(float value);
			static Radian ATan(float value) { return Radian(atan(value)); }
			static Radian ATan2(float fY,float fX) { return Radian(atan2(fY,fX)); }
			
        public: 
            static const float POS_INFINITY;
            static const float NEG_INFINITY;
            static const float PI;
            static const float TWO_PI;
            static const float HALF_PI;
            static const float fDeg2Rad;
            static const float fRad2Deg;
			static const float EPSILON;
			
			
        };
}



#endif
